//
//  MainViewController.m
//  PSYWeiBo
//
//  Created by xiaotian on 16/3/14.
//  Copyright © 2016年 郑亚田. All rights reserved.
//

#import "MainViewController.h"
#import <Masonry/Masonry.h>
#import "DiaryWallViewController.h"
//#import "DiaryWallViewController.h"
#import "CalendarViewController.h"
#import "TimeLineViewController.h"
#import "MyAlbumViewController.h"
#import "DiaryBookViewController.h"

@interface MainViewController ()

//主界面背景图
@property (nonatomic,strong)UIImageView *backImgV;
//签到图片
@property (nonatomic,strong)UIImageView *clickImgV;

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor cyanColor];
    self.backImgV = [UIImageView new];
    [self.view addSubview:self.backImgV];
    //打开用户交互(imageview默认是关闭状态)
    self.backImgV.userInteractionEnabled = YES;
    self.backImgV.image = [UIImage imageNamed:@"home-page-5@2x.jpg"];
    [self.backImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.view.bounds.size);
    }];
    
    self.clickImgV = [UIImageView new];
    [self.view addSubview:self.clickImgV];
    self.clickImgV.image = [UIImage imageNamed:@"sign@2x"];
    [self.clickImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.04);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.82);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.01);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.91);

    }];

    
    [self setButtonsAndLabels];
    
    
        
    }];
    
    [self setButtonsAndLabels];
}

-(void)setButtonsAndLabels {
    //timeBtn
    UIButton *timeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [timeBtn setBackgroundImage:[UIImage imageNamed:@"timelineIcon@3x"] forState:UIControlStateNormal];
    [timeBtn setBackgroundImage:[UIImage imageNamed:@"timelineIcon@2x"] forState:UIControlStateNormal];
    [self.backImgV addSubview:timeBtn];
    [timeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.04);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.84);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.89);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.05);
    }];
    [timeBtn addTarget:self action:@selector(timeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //timeLabel
    UILabel *timeLabel = [[UILabel alloc]init];
    timeLabel.text = @"时间轴";
    timeLabel.textAlignment = NSTextAlignmentCenter;
    timeLabel.font = [UIFont systemFontOfSize:15];
//    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    timeLabel.font = [UIFont systemFontOfSize:13];
    //    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    timeLabel.textColor = [UIColor colorWithRed:(251)/255.0 green:(71)/255.0 blue:(114)/255.0 alpha:1.0];
    [self.backImgV addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.04);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.84);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.93);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.01);
    }];
    
    //photoBtn
    UIButton *photoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [photoBtn setBackgroundImage:[UIImage imageNamed:@"albumIcon"] forState:UIControlStateNormal];
    [self.backImgV addSubview:photoBtn];
    [photoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.23);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.66);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.89);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.05);
    }];
    //photoLabel
    UILabel *photoLabel = [[UILabel alloc]init];
    photoLabel.text = @"相册";
    photoLabel.font = [UIFont systemFontOfSize:15];
    photoLabel.textAlignment = NSTextAlignmentCenter;
//    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    [photoBtn addTarget:self action:@selector(photoBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    //photoLabel
    UILabel *photoLabel = [[UILabel alloc]init];
    photoLabel.text = @"相册";
    photoLabel.font = [UIFont systemFontOfSize:13];
    photoLabel.textAlignment = NSTextAlignmentCenter;
    //    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    photoLabel.textColor = [UIColor colorWithRed:(251)/255.0 green:(71)/255.0 blue:(114)/255.0 alpha:1.0];
    [self.backImgV addSubview:photoLabel];
    [photoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.23);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.66);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.93);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.01);
    }];
    
    //calendarBtn
    UIButton *calendarBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [calendarBtn setBackgroundImage:[UIImage imageNamed:@"calendarIcon@2x"] forState:UIControlStateNormal];
    [self.backImgV addSubview:calendarBtn];
    [calendarBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.43);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.46);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.89);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.05);
    }];
    //calendarLabel
    UILabel *calendarLabel = [[UILabel alloc]init];
    calendarLabel.text = @"日历";
    calendarLabel.font = [UIFont systemFontOfSize:15];
    [calendarBtn addTarget:self action:@selector(calendarBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //calendarLabel
    UILabel *calendarLabel = [[UILabel alloc]init];
    calendarLabel.text = @"日历";
    calendarLabel.font = [UIFont systemFontOfSize:13];
    calendarLabel.textAlignment = NSTextAlignmentCenter;
    //    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    calendarLabel.textColor = [UIColor colorWithRed:(251)/255.0 green:(71)/255.0 blue:(114)/255.0 alpha:1.0];
    [self.backImgV addSubview:calendarLabel];
    [calendarLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.43);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.46);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.93);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.01);
    }];

    
    //diaryBtn
    UIButton *diaryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [diaryBtn setBackgroundImage:[UIImage imageNamed:@"diaryIcon"] forState:UIControlStateNormal];
    [self.backImgV addSubview:diaryBtn];
    [diaryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.63);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.26);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.89);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.05);
    }];
    //diaryLabel
    UILabel *diaryLabel = [[UILabel alloc]init];
    diaryLabel.text = @"日记集";
    diaryLabel.font = [UIFont systemFontOfSize:15];
    [diaryBtn addTarget:self action:@selector(diaryBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //diaryLabel
    UILabel *diaryLabel = [[UILabel alloc]init];
    diaryLabel.text = @"日记集";
    diaryLabel.font = [UIFont systemFontOfSize:13];
    diaryLabel.textAlignment = NSTextAlignmentCenter;
    //    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    diaryLabel.textColor = [UIColor colorWithRed:(251)/255.0 green:(71)/255.0 blue:(114)/255.0 alpha:1.0];
    [self.backImgV addSubview:diaryLabel];
    [diaryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.63);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.26);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.93);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.01);
    }];

    
    //markBtn
    UIButton *markBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [markBtn setBackgroundImage:[UIImage imageNamed:@"searchIcon@2x"] forState:UIControlStateNormal];
    [self.backImgV addSubview:markBtn];
    [markBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.83);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.06);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.89);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.05);
    }];
    //markLabel
    UILabel *markLabel = [[UILabel alloc]init];
    markLabel.text = @"日记集";
    markLabel.font = [UIFont systemFontOfSize:15];
    markLabel.text = @"纪念日";
    markLabel.font = [UIFont systemFontOfSize:13];
    markLabel.textAlignment = NSTextAlignmentCenter;
    //    [UIFont fontWithName:@"MakerFelt-Thin" size:20];
    markLabel.textColor = [UIColor colorWithRed:(251)/255.0 green:(71)/255.0 blue:(114)/255.0 alpha:1.0];
    [self.backImgV addSubview:markLabel];
    [markLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.83);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.06);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.93);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.01);
    }];
    
    //日记墙button
    UIButton *dayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    dayBtn.backgroundColor = [UIColor redColor];
    //    dayBtn.backgroundColor = [UIColor redColor];
    [dayBtn setTitle:@"日记墙" forState:UIControlStateNormal];
    [dayBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [self.backImgV addSubview:dayBtn];
    
    [dayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.4);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.3);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.23);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.71);
       
    }];
     [dayBtn addTarget:self action:@selector(dayBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        
    }];
    [dayBtn addTarget:self action:@selector(dayBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //记点滴button
    UIButton *notesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    notesBtn.backgroundColor = [UIColor redColor];
    //    notesBtn.backgroundColor = [UIColor redColor];
    [notesBtn setTitle:@"记点滴" forState:UIControlStateNormal];
    [notesBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [self.backImgV addSubview:notesBtn];
    [notesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.15);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.7);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.4);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.55);
    }];
    
    //写日记button
    UIButton *writeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    writeBtn.backgroundColor = [UIColor redColor];
    //    writeBtn.backgroundColor = [UIColor redColor];
    [writeBtn setTitle:@"写日记" forState:UIControlStateNormal];
    [writeBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [self.backImgV addSubview:writeBtn];
    [writeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.75);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.1);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.45);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.5);
    }];
    //设置button
    UIButton *setBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    setBtn.backgroundColor = [UIColor redColor];
    //    setBtn.backgroundColor = [UIColor redColor];
    [setBtn setTitle:@"设置" forState:UIControlStateNormal];
    [setBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [self.backImgV addSubview:setBtn];
    [setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.82);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.04);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.06);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.88);
    }];
    
    //签到button
    UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    clickBtn.backgroundColor = [UIColor redColor];
    //    clickBtn.backgroundColor = [UIColor redColor];
    [clickBtn setTitle:@"签到" forState:UIControlStateNormal];
    [clickBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    [self.backImgV addSubview:clickBtn];
    [clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
      
        make.left.equalTo(self.view).with.offset(kScreenWidth *0.04);
        make.right.equalTo(self.view).with.offset(-kScreenWidth *0.82);
        make.top.equalTo(self.view).with.offset(kScreenHeight *0.06);
        make.bottom.equalTo(self.view).with.offset(-kScreenHeight *0.88);
    }];
    
}

#pragma mark - btn点击事件们
-(void)dayBtnAction:(UIButton *)sender {
//    DiaryWallViewController *dwVC = [[DiaryWallViewController alloc]init];
//    [self presentViewController:dwVC animated:YES completion:nil];
}

- (void)diaryBtnClick:(UIButton *)sender {
    DiaryBookViewController  *diaryBook = [DiaryBookViewController new];
    diaryBook.modalTransitionStyle = 2;
    [self presentViewController:diaryBook animated:YES completion:nil];
}

- (void)photoBtnClick:(UIButton *)sender {
    MyAlbumViewController *album = [MyAlbumViewController new];
    album.modalTransitionStyle = 2;
    [self presentViewController:album animated:YES completion:nil];
}

- (void)calendarBtnClick:(UIButton *)sender {
    CalendarViewController *calendar = [CalendarViewController new];
    calendar.modalTransitionStyle = 2;
    [self presentViewController:calendar animated:YES completion:nil];
}

- (void)timeBtnClick:(UIButton *)sender {
    TimeLineViewController *timeLine = [TimeLineViewController new];
    timeLine.modalTransitionStyle = 2;
    [self presentViewController:timeLine animated:YES completion:nil];
>>>>>>> 84f81bc46dfa1cab68cf8b7273b8f98c23e37e83
}

-(void)dayBtnAction:(UIButton *)sender {
    DiaryWallViewController *dwVC = [[DiaryWallViewController alloc]init];
    dwVC.modalTransitionStyle = 2;
    [self presentViewController:dwVC animated:YES completion:nil];
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
